<?php

require_once(str_replace("\\", "/", dirname(dirname(dirname(__FILE__)))) . "/lib/Vendor/PhotoResize.php");

$p = $_GET["p"];


$ConArr = array(
    'ROOT_PATH' => dirname(dirname(__FILE__)), //www根目錄（後不要留“/”）
    "FILE" => dirname(__FILE__),
    "DOCUMENT_ROOT" => $_SERVER["DOCUMENT_ROOT"],
    "fromDirP" => 'upload',
    "toDirP" => 'supload',
    "pic" => $p,
    "isFixedSize" => 1,
    //默認配置可以寫在這裡
    'fit' => 0,
    'fit_color' => '#ffffff'
);

$PicConfig = array(//縮略圖配置
    "report_300_200" => array(
        "fromDir" => 'report', //原圖目錄
        "cut" => array(
            "w" => 300,
            "h" => 200,
            "x" => 0,
            "y" => 0,
            'auto' => 1
        )
    ),
    "product_300_200" => array(
        "fromDir" => 'product', //原圖目錄
        "cut" => array(
            "w" => 300,
            "h" => 200,
            "x" => 0,
            "y" => 0,
            'auto' => 1
        )
    ),
    "report_800_800" => array(
        "fromDir" => 'report', //原圖目錄
        "cut" => array(
            "w" => 800,
            "h" => 800,
            "x" => 0,
            "y" => 0,
            'auto' => 1
        )
    ),
    "product_800_800" => array(
        "fromDir" => 'product', //原圖目錄
        "cut" => array(
            "w" => 300,
            "h" => 200,
            "x" => 0,
            "y" => 0,
            'auto' => 1
        )
    ),
	
);
if (strpos($p, $ConArr["toDirP"]) === 1) {
    $tempP = str_replace("/" . $ConArr["toDirP"] . "/", "", $p);
    $pDirArr = explode("/", $tempP);
    $key = $pDirArr[0];
    $config = $PicConfig[$key];

    if ($config) {
        $config["toDir"] = $key;
        PhotoResize($ConArr, $config);
    }
}
?>